package com.xingxuecn.limit.web.action;

import com.opensymphony.xwork2.ActionSupport;
import com.xingxuecn.limit.common.model.TreeNode;
import com.xingxuecn.limit.common.utils.ResponseUtils;
import com.xingxuecn.limit.service.MenuService;
import com.xingxuecn.limit.service.impl.MenuServiceImpl;

import org.apache.struts2.ServletActionContext;

import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

/**
 * @author Kris at 2018/9/5 14:37
 */
public class IndexAction extends ActionSupport {
    private MenuService menuService = new MenuServiceImpl();

    public String index(){
        return SUCCESS;
    }
    
    public String loadMenuTree() throws SQLException {
        HttpServletResponse response = ServletActionContext.getResponse();
        List<TreeNode> treeNodeList = menuService.menuTree();
        ResponseUtils.writeJson(treeNodeList,response);
        return null;
    }
    
}
